home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / clarion / disabl.exe / CONTA003.CLW < prev    next >
Text File  |  1995-01-05  |  24KB  |  704 lines

  1.                      MEMBER('CONTACTS.clw')       ! This is a MEMBER module
  2. ReportByLastName PROCEDURE
  3. RejectRecord         LONG,AUTO
  4. LocalRequest         LONG,AUTO
  5. LocalResponse        LONG,AUTO
  6. WindowOpened         LONG,AUTO
  7. RecordsToProcess     LONG,AUTO
  8. RecordsProcessed     LONG,AUTO
  9. RecordsPerCycle      LONG,AUTO
  10. RecordsThisCycle     LONG,AUTO
  11. PercentProgress      DECIMAL(4,1)
  12. RecordStatus         BYTE,AUTO
  13. report               REPORT,AT(1000,2000,6000,7000),PRE(RPT),FONT('Arial',10,,),THOUS
  14.                        HEADER,AT(1000,1000,6000,1000)
  15.                        END
  16. detail                 DETAIL
  17.                          STRING(@s20),AT(0,0,,),USE(CON:LastName)
  18.                          STRING(@s20),AT(0,200,,),USE(CON:FirstName)
  19.                          STRING(@s25),AT(0,400,,),USE(CON:Company)
  20.                          STRING(@s25),AT(0,600,,),USE(CON:Address1)
  21.                          STRING(@s25),AT(0,800,,),USE(CON:Address2)
  22.                          STRING(@s25),AT(0,1000,,),USE(CON:City)
  23.                          STRING(@s2),AT(0,1200,,),USE(CON:State)
  24.                          STRING(@s5),AT(0,1400,,),USE(CON:Zip)
  25.                          STRING(@p(###) ###-####p),AT(0,1600,,),USE(CON:Phone)
  26.                          STRING(@p(###) ###-####p),AT(0,1800,,),USE(CON:Fax)
  27.                          STRING(@s25),AT(0,2000,,),USE(CON:JobTitle)
  28.                          STRING(@s45),AT(0,2200,,),USE(CON:Interest)
  29.                          STRING(@s15),AT(0,2400,,),USE(CON:TimeFrame)
  30.                          STRING(@s25),AT(0,2600,,),USE(CON:CurrentSoftware)
  31.                          STRING(@s45),AT(0,2800,,),USE(CON:Remarks)
  32.                        END
  33.                        FOOTER,AT(1000,9000,6000,1000)
  34.                        END
  35.                      END
  36. ProgressWindow       WINDOW('Progress...'),AT(,,142,59),CENTER,TIMER(1),GRAY,DOUBLE
  37.                        STRING(''),AT(0,3,141,10),USE(?Progress:UserString),CENTER
  38.                        BOX,AT(15,15,111,12),COLOR(00H),FILL(0FFFFFFH)
  39.                        BOX,AT(21,18,100,6),COLOR(00H),FILL(0C0C0C0H)
  40.                        BOX,AT(21,18,100,6),USE(?Progress:Thermometer),FILL(0FFH)
  41.                        STRING(''),AT(0,30,141,10),USE(?Progress:PctText),CENTER
  42.                        BUTTON('Cancel'),AT(45,42,50,15),USE(?Progress:Cancel)
  43.                      END
  44.   CODE
  45.   LocalRequest = GlobalRequest
  46.   LocalResponse = RequestCancelled
  47.   CLEAR(GlobalRequest)
  48.   CLEAR(GlobalResponse)
  49.   IF contacts::Used = 0
  50.     CheckOpen(contacts,1)
  51.   END
  52.   contacts::Used += 1
  53.   OPEN(ProgressWindow)
  54.   RecordsToProcess = RECORDS(contacts)
  55.   RecordsPerCycle = 25
  56.   RecordsToProcess = RECORDS(contacts)
  57.   RecordsPerCycle = 25
  58.   RecordsProcessed = 0
  59.   PercentProgress = 0
  60.   ?Progress:Thermometer{Prop:Width} = 0
  61.   ?Progress:PctText{Prop:Text} = '0.0% Completed'
  62.     ProgressWindow{Prop:Text} = 'Printing Report'
  63.   ?Progress:UserString{Prop:Text}=''
  64.   ACCEPT
  65.     CASE EVENT()
  66.     OF Event:OpenWindow
  67.       SET(CON:Key_LastName)
  68.       LOOP
  69.         DO GetNextcontacts
  70.         DO ValidateRecord
  71.         EXECUTE RecordStatus
  72.           BEGIN
  73.             LocalResponse = RequestCancelled
  74.             BREAK
  75.           END
  76.           CYCLE
  77.         END
  78.         BREAK
  79.       END
  80.       IF LocalResponse = RequestCancelled
  81.         POST(Event:CloseWindow)
  82.         CYCLE
  83.       END
  84.       OPEN(report)
  85.     OF Event:Timer
  86.       LOOP RecordsPerCycle TIMES
  87.         PRINT(RPT:detail)
  88.         LOOP
  89.           DO GetNextRecord
  90.           DO ValidateRecord
  91.           EXECUTE RecordStatus
  92.             BEGIN
  93.               LocalResponse = RequestCancelled
  94.               BREAK
  95.             END
  96.             CYCLE
  97.           END
  98.           BREAK
  99.         END
  100.         IF LocalResponse = RequestCancelled
  101.           LocalResponse = RequestCompleted
  102.           BREAK
  103.         END
  104.         LocalResponse = RequestCancelled
  105.       END
  106.       IF LocalResponse = RequestCompleted
  107.         POST(Event:CloseWindow)
  108.       END
  109.     END
  110.     CASE FIELD()
  111.     OF ?Progress:Cancel
  112.       CASE Event()
  113.       OF Event:Accepted
  114.         LocalResponse = RequestCancelled
  115.         POST(Event:CloseWindow)
  116.       END
  117.     END
  118.   END
  119.   contacts::Used -= 1
  120.   IF contacts::Used = 0 THEN CLOSE(contacts).
  121.   IF LocalResponse
  122.     GlobalResponse = LocalResponse
  123.   ELSE
  124.     GlobalResponse = RequestCancelled
  125.   END
  126.   RETURN
  127. !-----------------------------------------------------------------------------
  128. ValidateRecord       ROUTINE
  129.   RecordStatus = Record:OutOfRange
  130.   IF LocalResponse = RequestCancelled THEN EXIT.
  131.   IF ERRORCODE() THEN EXIT.
  132.   RecordStatus = Record:OK
  133.   EXIT
  134. GetNextcontacts ROUTINE
  135.   LocalResponse = RequestCancelled
  136.   LOOP
  137.     NEXT(contacts)
  138.     IF ERRORCODE() THEN EXIT.
  139.     RecordsProcessed += 1
  140.     RecordsThisCycle += 1
  141.     IF PercentProgress < 100
  142.       PercentProgress = (RecordsProcessed / RecordsToProcess)*100
  143.       IF PercentProgress > 100
  144.         PercentProgress = 100
  145.       END
  146.       ?Progress:Thermometer{Prop:Width} = ROUND(PercentProgress,0)
  147.       ?Progress:PctText{Prop:Text} = FORMAT(PercentProgress,@N5.1) & '% Completed'
  148.       DISPLAY()
  149.     END
  150.     BREAK
  151.   END
  152.   LocalResponse = RequestCompleted
  153.   EXIT
  154.  
  155. GetNextRecord ROUTINE
  156.   DO GetNextcontacts
  157.   IF LocalResponse = RequestCompleted THEN EXIT.
  158. BrowseByLastName PROCEDURE
  159.  
  160. LocalRequest         LONG,AUTO
  161. OriginalRequest      LONG,AUTO
  162. LocalResponse        LONG,AUTO
  163. WindowOpened         LONG
  164. WindowInitialized    LONG
  165. ForceRefresh         LONG,AUTO
  166. RecordFiltered       LONG
  167. Queue:Browse         QUEUE                        ! Browsing Queue
  168. Brw1::CON:LastName     LIKE(CON:LastName)         ! Queue Display field
  169. Brw1::CON:FirstName    LIKE(CON:FirstName)        ! Queue Display field
  170. Brw1::CON:Company      LIKE(CON:Company)          ! Queue Display field
  171. Brw1::CON:Address1     LIKE(CON:Address1)         ! Queue Display field
  172. Brw1::CON:Address2     LIKE(CON:Address2)         ! Queue Display field
  173. Brw1::CON:City         LIKE(CON:City)             ! Queue Display field
  174. Brw1::CON:State        LIKE(CON:State)            ! Queue Display field
  175. Brw1::CON:Zip          LIKE(CON:Zip)              ! Queue Display field
  176. Brw1::CON:Phone        LIKE(CON:Phone)            ! Queue Display field
  177. Brw1::CON:Fax          LIKE(CON:Fax)              ! Queue Display field
  178. Brw1::CON:JobTitle     LIKE(CON:JobTitle)         ! Queue Display field
  179. Brw1::CON:Interest     LIKE(CON:Interest)         ! Queue Display field
  180. Brw1::CON:TimeFrame    LIKE(CON:TimeFrame)        ! Queue Display field
  181. Brw1::CON:CurrentSoftware LIKE(CON:CurrentSoftware) ! Queue Display field
  182. Brw1::CON:Remarks      LIKE(CON:Remarks)          ! Queue Display field
  183. Brw1::Position         STRING(255)                ! Queue POSITION information
  184.                      END                          ! END (Browsing Queue)
  185. Brw1::RecordStatus   BYTE                         ! Flag for Range/Filter test
  186. Brw1::ItemsToFill    LONG                         ! Controls records retrieved
  187. Brw1::MaxItemsInList LONG                         ! Retrieved after window opened
  188. Brw1::LocatedPosition STRING(255)                 ! POSITION of located record
  189. Brw1::QueuePointer   LONG                         ! Queue position of located record
  190. Brw1::NextChoice     LONG                         ! Queue position of located record
  191. Brw1::CurrentScroll  BYTE                         ! Queue position of scroll thumb
  192. BrowseLastWindow     WINDOW('Browse by Last Name'),AT(,,247,129),FONT('Arial',10,,),SYSTEM,GRAY,MDI
  193.                        LIST,AT(5,5,235,100),FONT('Arial',9,,),MSG('Browsing Records'),USE(?List),IMM,HVSCROLL,FORMAT('80L~Last Name~@s20@80L~First Name~@s20@80L~Company~@s25@80L~Address 1~@s25@80L~A' &|
  194.    'ddress 2~@s25@80L~City~@s25@80L~State~@s2@80L~Zip~@s5@80L~Phone~@p(###) ###-####' &|
  195.    'p@80L~Fax~@p(###) ###-####p@80L~Job Title~@s25@80L~Interest~@s45@80L~Time Frame~' &|
  196.    '@s15@80L~Current Software~@s25@80L~Remarks~@s45@'),FROM(Queue:Browse)
  197.                        BUTTON('&Insert'),AT(5,110,45,12),USE(?Insert)
  198.                        BUTTON('&Change'),AT(50,110,45,12),USE(?Change),DEFAULT
  199.                        BUTTON('&Delete'),AT(95,110,45,12),USE(?Delete)
  200.                        BUTTON('&Select'),AT(145,110,40,12),USE(?Select)
  201.                        BUTTON('Close'),AT(200,110,40,12),USE(?Close)
  202.                      END
  203.   CODE
  204.   LocalRequest = GlobalRequest
  205.   OriginalRequest = GlobalRequest
  206.   LocalResponse = RequestCancelled
  207.   CLEAR(GlobalRequest)
  208.   CLEAR(GlobalResponse)
  209.   IF contacts::Used = 0
  210.     CheckOpen(contacts,1)
  211.   END
  212.   contacts::Used += 1
  213.   OPEN(BrowseLastWindow)
  214.   WindowOpened=True
  215.   SET(CON:Key_LastName)
  216.   ?List{Prop:Alrt,251} = MouseLeft2
  217.   IF LocalRequest = SelectRecord
  218.     ENABLE(?Select)
  219.     ?Select{Prop:Default} = True
  220.   ELSE
  221.     DISABLE(?Select)
  222.   END
  223.   ?List{Prop:Alrt,255} = InsertKey
  224.   ?List{Prop:Alrt,254} = DeleteKey
  225.   ?List{Prop:Alrt,253} = CtrlEnter
  226.   ACCEPT
  227.     CASE EVENT()
  228.     OF EVENT:CloseWindow
  229.       !Enables Button1
  230.       AppRef1$ButtonRef1{Prop:DISABLE}=0
  231.       DO RefreshWindow
  232.     OF EVENT:OpenWindow
  233.       IF NOT WindowInitialized
  234.         DO InitializeWindow
  235.       END
  236.       SELECT(?List)
  237.     OF EVENT:GainFocus
  238.       WindowInitialized = True
  239.       DO InitializeWindow
  240.     END
  241.     CASE FIELD()
  242.     OF ?List
  243.       CASE EVENT()
  244.       OF EVENT:Accepted
  245.         DO Brw1::FillBuffer
  246.         DO RefreshWindow
  247.       OF EVENT:NewSelection
  248.         DO Brw1::FillBuffer
  249.         DO RefreshWindow
  250.       OF EVENT:ScrollUp
  251.         DO Brw1::ScrollUp
  252.         DO RefreshWindow
  253.       OF EVENT:ScrollDown
  254.         DO Brw1::ScrollDown
  255.         DO RefreshWindow
  256.       OF EVENT:PageUp
  257.         DO Brw1::PageUp
  258.         DO RefreshWindow
  259.       OF EVENT:PageDown
  260.         DO Brw1::PageDown
  261.         DO RefreshWindow
  262.       OF EVENT:ScrollTop
  263.         DO Brw1::ScrollTop
  264.         DO RefreshWindow
  265.       OF EVENT:ScrollBottom
  266.         DO Brw1::ScrollBottom
  267.         DO RefreshWindow
  268.       OF EVENT:AlertKey
  269.         DO Brw1::AlertKey
  270.         DO RefreshWindow
  271.       END
  272.     OF ?Insert
  273.       CASE EVENT()
  274.       OF EVENT:Accepted
  275.         DO SyncWindow
  276.         DO Brw1::ButtonInsert
  277.         DO RefreshWindow
  278.       END
  279.     OF ?Change
  280.       CASE EVENT()
  281.       OF EVENT:Accepted
  282.         DO SyncWindow
  283.         DO Brw1::ButtonChange
  284.         DO RefreshWindow
  285.       END
  286.     OF ?Delete
  287.       CASE EVENT()
  288.       OF EVENT:Accepted
  289.         DO SyncWindow
  290.         DO Brw1::ButtonDelete
  291.         DO RefreshWindow
  292.       END
  293.     OF ?Select
  294.       CASE EVENT()
  295.       OF EVENT:Accepted
  296.         DO SyncWindow
  297.         LocalResponse = RequestCompleted
  298.         POST(Event:CloseWindow)
  299.         CYCLE
  300.         DO RefreshWindow
  301.       END
  302.     OF ?Close
  303.       CASE EVENT()
  304.       OF EVENT:Accepted
  305.         DO SyncWindow
  306.         LocalResponse = RequestCancelled
  307.         POST(Event:CloseWindow)
  308.         DO RefreshWindow
  309.       END
  310.     END
  311.   END
  312.   contacts::Used -= 1
  313.   IF contacts::Used = 0 THEN CLOSE(contacts).
  314.   IF WindowOpened
  315.     CLOSE(BrowseLastWindow)
  316.   END
  317.   IF LocalResponse
  318.     GlobalResponse = LocalResponse
  319.   ELSE
  320.     GlobalResponse = RequestCancelled
  321.   END
  322.   RETURN
  323. !---------------------------------------------------------------------------
  324. InitializeWindow ROUTINE
  325.   DO Brw1::OpenWindow
  326.   ForceRefresh = True
  327.   DO RefreshWindow
  328. !---------------------------------------------------------------------------
  329. RefreshWindow ROUTINE
  330.   IF ForceRefresh
  331.     GET(Queue:Browse,CHOICE(?List))
  332.     REGET(CON:Key_LastName,Brw1::Position)
  333.     DO Brw1::ValidateRecord
  334.     IF Brw1::RecordStatus <> Record:OK
  335.       FREE(Queue:Browse)
  336.       SET(CON:Key_LastName)
  337.       DO Brw1::RefreshPage
  338.     ELSE
  339.       DO Brw1::LocateRecord
  340.     END
  341.   ELSE
  342.     DO Brw1::ValidateRecord
  343.     IF Brw1::RecordStatus <> Record:OK
  344.       FREE(Queue:Browse)
  345.       SET(CON:Key_LastName)
  346.       DO Brw1::RefreshPage
  347.     END
  348.   END
  349.   ?List{Prop:VScrollPos} = Brw1::CurrentScroll
  350.   DISPLAY()
  351.   ForceRefresh = False
  352. !---------------------------------------------------------------------------
  353. SyncWindow ROUTINE
  354.   IF RECORDS(Queue:Browse)
  355.     GET(Queue:Browse,CHOICE(?List))
  356.     REGET(CON:Key_LastName,Brw1::Position)
  357.   END
  358. !---------------------------------------------------------------------------
  359. Brw1::OpenWindow ROUTINE
  360.   IF LocalRequest = SelectRecord
  361.     SET(CON:Key_LastName,CON:Key_LastName)
  362.     DO Brw1::LocateRecord
  363.   ELSE
  364.     SET(CON:Key_LastName)
  365.     DO Brw1::RefreshPage
  366.     SELECT(?List,1)
  367.   END
  368.   DO Brw1::FillBuffer
  369. !----------------------------------------------------------------------
  370. Brw1::FillBuffer ROUTINE
  371.   GET(Queue:Browse,CHOICE(?List))
  372.   CON:LastName = Brw1::CON:LastName
  373.   CON:FirstName = Brw1::CON:FirstName
  374.   CON:Company = Brw1::CON:Company
  375.   CON:Address1 = Brw1::CON:Address1
  376.   CON:Address2 = Brw1::CON:Address2
  377.   CON:City = Brw1::CON:City
  378.   CON:State = Brw1::CON:State
  379.   CON:Zip = Brw1::CON:Zip
  380.   CON:Phone = Brw1::CON:Phone
  381.   CON:Fax = Brw1::CON:Fax
  382.   CON:JobTitle = Brw1::CON:JobTitle
  383.   CON:Interest = Brw1::CON:Interest
  384.   CON:TimeFrame = Brw1::CON:TimeFrame
  385.   CON:CurrentSoftware = Brw1::CON:CurrentSoftware
  386.   CON:Remarks = Brw1::CON:Remarks
  387. !----------------------------------------------------------------------
  388. Brw1::FillQueue ROUTINE
  389.   Brw1::CON:LastName = CON:LastName
  390.   Brw1::CON:FirstName = CON:FirstName
  391.   Brw1::CON:Company = CON:Company
  392.   Brw1::CON:Address1 = CON:Address1
  393.   Brw1::CON:Address2 = CON:Address2
  394.   Brw1::CON:City = CON:City
  395.   Brw1::CON:State = CON:State
  396.   Brw1::CON:Zip = CON:Zip
  397.   Brw1::CON:Phone = CON:Phone
  398.   Brw1::CON:Fax = CON:Fax
  399.   Brw1::CON:JobTitle = CON:JobTitle
  400.   Brw1::CON:Interest = CON:Interest
  401.   Brw1::CON:TimeFrame = CON:TimeFrame
  402.   Brw1::CON:CurrentSoftware = CON:CurrentSoftware
  403.   Brw1::CON:Remarks = CON:Remarks
  404.   Brw1::Position = POSITION(CON:Key_LastName)
  405. !----------------------------------------------------------------------
  406. Brw1::ScrollUp ROUTINE
  407.   IF CHOICE(?List)>1
  408.     SELECT(?List, CHOICE(?List)-1)
  409.     POST(Event:NewSelection,?List)
  410.   ELSE
  411.     GET(Queue:Browse,1)                           ! Get the first queue item
  412.     RESET(CON:Key_LastName,Brw1::Position)        ! Reset for sequential processing
  413.     NOMEMO(contacts)
  414.     PREVIOUS(contacts)                            ! Retrieve record, reverse access
  415.     Brw1::ItemsToFill = 1                         ! Load a single item
  416.     DO Brw1::FillBackward                         ! Fill with previous read(s)
  417.     IF Brw1::ItemsToFill                          ! If Load failed
  418.       Brw1::CurrentScroll = 0                     ! Move Thumb to top
  419.     ELSE
  420.       Brw1::CurrentScroll = 50                    ! Move Thumb to center
  421.     END
  422.   END
  423. !----------------------------------------------------------------------
  424. Brw1::ScrollDown ROUTINE
  425.   IF CHOICE(?List)<RECORDS(Queue:Browse)
  426.     SELECT(?List, CHOICE(?List)+1)
  427.     POST(Event:NewSelection,?List)
  428.   ELSE
  429.     GET(Queue:Browse,RECORDS(Queue:Browse))       ! Get the last queue item
  430.     RESET(CON:Key_LastName,Brw1::Position)        ! Reset for sequential processing
  431.     NOMEMO(contacts)
  432.     NEXT(contacts)                                ! Retrieve record, forward access
  433.     Brw1::ItemsToFill = 1                         ! load a single item
  434.     DO Brw1::FillForward                          ! Fill with next read(s)
  435.     IF Brw1::ItemsToFill                          ! If Load failed
  436.       Brw1::CurrentScroll = 100                   ! Move Thumb to top
  437.     ELSE
  438.       Brw1::CurrentScroll = 50                    ! Move Thumb to center
  439.     END
  440.   END
  441. !----------------------------------------------------------------------
  442. Brw1::PageUp ROUTINE
  443.   GET(Queue:Browse,1)                             ! Get the first queue item
  444.   RESET(CON:Key_LastName,Brw1::Position)          ! Reset for sequential processing
  445.   NOMEMO(contacts)
  446.   PREVIOUS(contacts)                              ! Retrieve record, reverse access
  447.   Brw1::ItemsToFill = ?List{Prop:Items}           ! Load a full page
  448.   DO Brw1::FillBackward                           ! Fill with previous read(s)
  449.   IF Brw1::ItemsToFill
  450.     Brw1::NextChoice = CHOICE(?List)-Brw1::ItemsToFill
  451.     IF Brw1::NextChoice < 1
  452.       Brw1::NextChoice = 1
  453.     END
  454.     SELECT(?List, Brw1::NextChoice)
  455.     Brw1::CurrentScroll = 0                       ! Move Thumb to top
  456.   ELSE
  457.     Brw1::CurrentScroll = 50                      ! Move Thumb to center
  458.   END
  459. !----------------------------------------------------------------------
  460. Brw1::PageDown ROUTINE
  461.   GET(Queue:Browse,RECORDS(Queue:Browse))         ! Get the last queue item
  462.   RESET(CON:Key_LastName,Brw1::Position)          ! Reset for sequential processing
  463.   NOMEMO(contacts)
  464.   NEXT(contacts)                                  ! Retrieve record, forward access
  465.   Brw1::ItemsToFill = ?List{Prop:Items}           ! Load a full page
  466.   DO Brw1::FillForward                            ! Fill with next read(s)
  467.   IF Brw1::ItemsToFill
  468.     Brw1::NextChoice = CHOICE(?List)+Brw1::ItemsToFill
  469.     IF Brw1::NextChoice > RECORDS(Queue:Browse)
  470.       Brw1::NextChoice = RECORDS(Queue:Browse)
  471.     END
  472.     SELECT(?List, Brw1::NextChoice)
  473.     Brw1::CurrentScroll = 100                     ! Move Thumb to top
  474.   ELSE
  475.     Brw1::CurrentScroll = 50                      ! Move Thumb to center
  476.   END
  477. !----------------------------------------------------------------------
  478. Brw1::ScrollTop ROUTINE
  479.   FREE(Queue:Browse)                              ! Free the browse queue
  480.   SET(CON:Key_LastName)
  481.   DO Brw1::RefreshPage
  482.   SELECT(?List,1)                                 ! Select first list item
  483.   Brw1::CurrentScroll = 0
  484. !----------------------------------------------------------------------
  485. Brw1::ScrollBottom ROUTINE
  486.   SETCURSOR(Cursor:Wait)
  487.   FREE(Queue:Browse)                              ! Free the browse queue
  488.   SET(CON:Key_LastName)
  489.   Brw1::ItemsToFill = ?List{Prop:Items}           ! Load a full page
  490.   DO Brw1::FillBackward                           ! Fill with previous read(s)
  491.   SELECT(?List, RECORDS(Queue:Browse))            ! Select last list item
  492.   IF RECORDS(Queue:Browse) = ?List{Prop:Items}
  493.     Brw1::CurrentScroll = 100
  494.   ELSE
  495.     Brw1::CurrentScroll = 0
  496.   END
  497.   SETCURSOR()
  498. !----------------------------------------------------------------------
  499. Brw1::AlertKey ROUTINE
  500.   CASE KEYCODE()                                  ! What keycode was hit
  501.   OF MouseLeft2
  502.     IF LocalRequest = SelectRecord
  503.       POST(Event:Accepted,?Select)
  504.       EXIT
  505.     END
  506.     POST(Event:Accepted,?Change)
  507.     EXIT
  508.   OF InsertKey
  509.     POST(Event:Accepted,?Insert)
  510.   OF DeleteKey
  511.     POST(Event:Accepted,?Delete)
  512.   OF CtrlEnter
  513.     POST(Event:Accepted,?Change)
  514.   ELSE                                            ! ELSE (What keycode was hit)
  515.     IF CHR(KEYCHAR())
  516.       SET(CON:Key_LastName)
  517.       CON:LastName = CHR(KEYCHAR())
  518.       DO Brw1::LocateRecord                       ! Find the record
  519.     END
  520.   END                                             ! END (What keycode was hit)
  521. !----------------------------------------------------------------------
  522. Brw1::ValidateRecord ROUTINE
  523.   Brw1::RecordStatus = Record:OutOfRange
  524.   IF ERRORCODE() THEN EXIT.
  525.   Brw1::RecordStatus = Record:OK
  526.   EXIT
  527. !----------------------------------------------------------------------
  528. Brw1::FillForward ROUTINE
  529.   LOOP WHILE Brw1::ItemsToFill
  530.     NEXT(contacts)
  531.     DO Brw1::ValidateRecord
  532.     EXECUTE(Brw1::RecordStatus)
  533.       BEGIN
  534.         SET(CON:Key_LastName)
  535.         BREAK
  536.       END
  537.       CYCLE
  538.     END
  539.     IF RECORDS(Queue:Browse) = ?List{Prop:Items}
  540.       GET(Queue:Browse,1)
  541.       DELETE(Queue:Browse)
  542.     END
  543.     Brw1::ItemsToFill -= 1
  544.     DO Brw1::FillQueue
  545.     ADD(Queue:Browse)
  546.   END
  547.   EXIT
  548. !----------------------------------------------------------------------
  549. Brw1::FillBackward ROUTINE
  550.   LOOP WHILE Brw1::ItemsToFill
  551.     PREVIOUS(contacts)
  552.     DO Brw1::ValidateRecord
  553.     EXECUTE(Brw1::RecordStatus)
  554.       BEGIN
  555.         SET(CON:Key_LastName)
  556.         BREAK
  557.       END
  558.       CYCLE
  559.     END
  560.     IF RECORDS(Queue:Browse) = ?List{Prop:Items}
  561.       GET(Queue:Browse,RECORDS(Queue:Browse))
  562.       DELETE(Queue:Browse)
  563.     END
  564.     Brw1::ItemsToFill -= 1
  565.     DO Brw1::FillQueue
  566.     ADD(Queue:Browse,1)
  567.   END
  568.   EXIT
  569. !----------------------------------------------------------------------
  570. Brw1::LocateRecord ROUTINE
  571.   SETCURSOR(Cursor:Wait)
  572.   FREE(Queue:Browse)
  573.   SET(CON:Key_LastName,CON:Key_LastName)
  574.   Brw1::LocatedPosition = ''
  575.   LOOP
  576.     NEXT(contacts)
  577.     DO Brw1::ValidateRecord                           
  578.     EXECUTE(Brw1::RecordStatus)
  579.       BREAK
  580.       CYCLE
  581.     END
  582.     Brw1::LocatedPosition = POSITION(CON:Key_LastName)
  583.     RESET(CON:Key_LastName,Brw1::LocatedPosition)
  584.     BREAK
  585.   END
  586.   Brw1::ItemsToFill = ?List{Prop:Items}
  587.   Brw1::CurrentScroll = 50
  588.   DO Brw1::FillForward
  589.   IF Brw1::ItemsToFill
  590.     Brw1::CurrentScroll = 100
  591.     IF ~RECORDS(Queue:Browse)
  592.       SET(CON:Key_LastName)
  593.     ELSE
  594.       GET(Queue:Browse,1)
  595.       RESET(CON:Key_LastName,Brw1::Position)
  596.       PREVIOUS(contacts)
  597.     END
  598.     DO Brw1::FillBackward
  599.     IF Brw1::ItemsToFill
  600.       Brw1::CurrentScroll = 0
  601.     END
  602.   END
  603.   IF ~RECORDS(Queue:Browse)
  604.     CLEAR(CON:Record)
  605.     CLEAR(CON:Remarks)
  606.     SET(CON:Key_LastName)
  607.     ?Change{Prop:Disable} = 1
  608.     ?Delete{Prop:Disable} = 1
  609.   ELSE
  610.     IF Brw1::LocatedPosition
  611.       Brw1::QueuePointer = 1
  612.       LOOP
  613.         GET(Queue:Browse,Brw1::QueuePointer)
  614.         IF ERRORCODE() THEN BREAK.
  615.         IF Brw1::Position = Brw1::LocatedPosition THEN BREAK.
  616.         Brw1::QueuePointer += 1
  617.       END
  618.     ELSE
  619.       Brw1::QueuePointer = RECORDS(Queue:Browse)
  620.     END
  621.     SELECT(?List,Brw1::QueuePointer)
  622.     DO Brw1::FillBuffer
  623.     REGET(CON:Key_LastName,Brw1::Position)
  624.     ?Change{Prop:Disable} = 0
  625.     ?Delete{Prop:Disable} = 0
  626.   END
  627.   SETCURSOR()
  628. !----------------------------------------------------------------------
  629. Brw1::RefreshPage ROUTINE
  630.   SETCURSOR(Cursor:Wait)
  631.   IF RECORDS(Queue:Browse)
  632.     GET(Queue:Browse,1)
  633.     RESET(CON:Key_LastName,Brw1::Position)
  634.     FREE(Queue:Browse)
  635.   END
  636.   Brw1::ItemsToFill = ?List{Prop:Items}
  637.   Brw1::CurrentScroll = 50
  638.   DO Brw1::FillForward
  639.   IF Brw1::ItemsToFill
  640.     GET(Queue:Browse,1)
  641.     RESET(CON:Key_LastName,Brw1::Position)
  642.     PREVIOUS(contacts)
  643.     Brw1::CurrentScroll = 100
  644.     DO Brw1::FillBackward
  645.     IF Brw1::ItemsToFill
  646.       Brw1::CurrentScroll = 0
  647.     END
  648.   END
  649.   IF ~RECORDS(Queue:Browse)
  650.     CLEAR(CON:Record)
  651.     CLEAR(CON:Remarks)
  652.     SET(CON:Key_LastName)
  653.     ?Change{Prop:Disable} = 1
  654.     ?Delete{Prop:Disable} = 1
  655.   ELSE
  656.     DO Brw1::FillBuffer
  657.     REGET(CON:Key_LastName,Brw1::Position)
  658.     ?Change{Prop:Disable} = 0
  659.     ?Delete{Prop:Disable} = 0
  660.   END
  661.   SETCURSOR()
  662. !----------------------------------------------------------------
  663. Brw1::ButtonInsert ROUTINE
  664.   GET(contacts,0)
  665.   CLEAR(CON:Record,0)
  666.   CLEAR(CON:Remarks)
  667.   SET(CON:Key_LastName)
  668.   GlobalRequest = InsertRecord
  669.   UpdateProc
  670.   IF GlobalResponse = RequestCompleted
  671.     DO Brw1::ValidateRecord
  672.     IF Brw1::RecordStatus = Record:OK
  673.       DO Brw1::LocateRecord
  674.     END
  675.   END
  676.   ForceRefresh = True
  677.   LocalRequest = OriginalRequest
  678. !----------------------------------------------------------------
  679. Brw1::ButtonChange ROUTINE
  680.   GlobalRequest = ChangeRecord
  681.   UpdateProc
  682.   IF GlobalResponse = RequestCompleted
  683.     DO Brw1::ValidateRecord
  684.     IF Brw1::RecordStatus = Record:OK
  685.       DO Brw1::LocateRecord
  686.     ELSE
  687.       SELECT(?List,CHOICE(?List))
  688.     END
  689.   END
  690.   ForceRefresh = True
  691.   LocalRequest = OriginalRequest
  692. !----------------------------------------------------------------
  693. Brw1::ButtonDelete ROUTINE
  694.   GlobalRequest = DeleteRecord
  695.   UpdateProc
  696.   IF GlobalResponse = RequestCompleted
  697.     DELETE(Queue:Browse)
  698.     DO Brw1::RefreshPage
  699.   END
  700.   SELECT(?List,CHOICE(?List))
  701.   ForceRefresh = True
  702.   LocalRequest = OriginalRequest
  703.  
  704.